<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script>
        window.onload=function (){
            findDept()
        }

        async function findDept(){
            let info=await ajaxGet("/dept/findAll");
            let str="";
            for (let i=0;i<info.length;i++){
                let obj=info[i];
                str+=`<option value="${obj.id}">${obj.name}</option>`;
            }
            getObject("deptSelect").innerHTML=str;
        }

        async function add(){
            let param={
                name:getObject("name").value,money:getObject("money").value,
                birthday:getObject("birthday").value,
                deptId:getObject("deptSelect").value
            };
            let info=await ajaxGet("/employee/add",param);
            if (info=="ok"){
                location.href="/html/index.html";
            }else {
                alert("添加失败")
            }
        }
    </script>
</head>
<body>
    姓名:<input type="text" id="name"><br>
    生日:<input type="text" id="birthday"><br>
    工资:<input type="text" id="money"><br>
    部门:<select id="deptSelect"></select><br>
    <input type="submit" value="添加" onclick="add()">
</body>
</html>